//
//  LGPatientRiskMonitorHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/8/2.
//

#import "LGPatientRiskMonitorHeader.h"
#import "LGScrollView.h"
#define zfTopMargin    viewPix(90)

#define cxTopMargin    viewPix(330)

#define leftMargin   viewPix(35)+iPadMargin(10)

#define lineHeight   viewPix(28)

#define scrollWidth    (Screen_W - viewPix(83))

#define scrollHeight (lineHeight*6+viewPix(20))
#define itemW  (Screen_W-viewPix(56))/4.0
@interface LGPatientRiskMonitorHeader()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *allButton;
@property (nonatomic , strong)UIButton *patientBtn;
@property (nonatomic , strong)UIButton *doctorBtn;
/**   */
@property (nonatomic , strong)UIButton *zfButton;
@property (nonatomic , strong)UILabel *zfStatus;
/**   */
@property (nonatomic , strong)UIButton *cxButton;
@property (nonatomic , strong)UILabel *cxStatus;
/**   */
@property (nonatomic , strong)LGScrollView *zfScrollView;
@property (nonatomic , strong)CAShapeLayer *zfShapeLayer;
@property (nonatomic , assign)NSInteger zfTotalCount;
@property (nonatomic , assign)CGFloat zfItemWidth;
@property (nonatomic , strong)NSArray *zfDataArray;
@property (nonatomic , strong)NSMutableArray *zfViewArray;

/**   */
@property (nonatomic , strong)LGScrollView *cxScrollView;
@property (nonatomic , strong)CAShapeLayer *cxShapeLayer;
@property (nonatomic , assign)NSInteger cxTotalCount;
@property (nonatomic , assign)CGFloat cxItemWidth;
@property (nonatomic , strong)NSArray *cxDataArray;
@property (nonatomic , strong)NSMutableArray *cxViewArray;

@property (nonatomic , strong)NSMutableArray *layerArray;
/**   */
@property (nonatomic , strong)NSDictionary *colorDic;
@property (nonatomic , strong)NSDictionary *iconDic;

@end

@implementation LGPatientRiskMonitorHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //1-低 、2-中 、 3-高
        self.colorDic = @{@"1":@"#5E8EF5",@"2":@"#FB670D",@"3":@"#C44E4E"};
        self.iconDic = @{@"1":@"风险监测-正常",@"2":@"风险监测-低风险",@"3":@"风险监测-高风险"};
        [self createSubView];
    }
    return self;
}

-(void)itemButtonSelect:(UIButton *)sender{
    self.allButton.selected = NO;
    self.patientBtn.selected = NO;
    self.doctorBtn.selected = NO;
    sender.selected = YES;
    NSString *type = @"";
    if(sender == self.patientBtn){
        type = @"1";
    }else if (sender == self.doctorBtn){
        type = @"2";
    }
    if(self.delegate && [self.delegate respondsToSelector:@selector(requestData:)]){
        [self.delegate requestData:type];
    }
}

-(void)showRiskTipView:(UIButton *)sender{
    NSString *title = (sender == self.zfButton)?@"中风风险":@"出血风险";
    NSString *content = (sender == self.zfButton)?@"CHA2DS2-VASc评分是目前应用最广泛的卒中风险评估工具。CHA2DS2‑VASc评分=0分的男性或=1分的女性为低风险；评分=1分的男性或=2分的女性为中风险；评分≥2 分的男性或≥3 分的女性为高风险。":@"HAS‑BLED出血评分是应用最广泛的出血风险预测模型。HAS‑BLED 评分≤2 分为低出血风险，评分≥3 分时提示高出血风险。";
    
    NSMutableAttributedString *attrbutStr = [[NSMutableAttributedString alloc]initWithString:content];
    if(sender == self.zfButton){
        [attrbutStr addAttributes:@{NSFontAttributeName:LGFontWeight(17, UIFontWeightMedium),NSForegroundColorAttributeName:[UIColor colorWithString:@"#5E8EF5"]} range:NSMakeRange(60, 3)];
        [attrbutStr addAttributes:@{NSFontAttributeName:LGFontWeight(17, UIFontWeightMedium),NSForegroundColorAttributeName:[UIColor colorWithString:@"#FB670D"]} range:NSMakeRange(80, 3)];
        [attrbutStr addAttributes:@{NSFontAttributeName:LGFontWeight(17, UIFontWeightMedium),NSForegroundColorAttributeName:[UIColor colorWithString:@"#C44E4E"]} range:NSMakeRange(102, 3)];
    }else{
        [attrbutStr addAttributes:@{NSFontAttributeName:LGFontWeight(17, UIFontWeightMedium),NSForegroundColorAttributeName:[UIColor colorWithString:@"#5E8EF5"]} range:NSMakeRange(44, 5)];
        [attrbutStr addAttributes:@{NSFontAttributeName:LGFontWeight(17, UIFontWeightMedium),NSForegroundColorAttributeName:[UIColor colorWithString:@"#C44E4E"]} range:NSMakeRange(59, 5)];
    }
   
    [LGAlertTool singleActionAlertWithTitle:title attrbutContent:attrbutStr sureAction:^{
        
    }];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.zfDataDic = dataDic[@"zhongfCharts"];
    self.cxDataDic = dataDic[@"chuxCharts"];
    self.zfStatus.text = LGNSString(dataDic[@"zhongf"]);
    self.cxStatus.text = LGNSString(dataDic[@"chux"]);
    NSString *zfColor = self.colorDic[LGNSString(dataDic[@"zhongf_status"])];
    NSString *cxColor = self.colorDic[LGNSString(dataDic[@"chux_status"])];
    self.zfStatus.textColor = [UIColor colorWithString:zfColor];
    self.cxStatus.textColor = [UIColor colorWithString:cxColor];
}

-(void)setZfDataDic:(NSDictionary *)zfDataDic{
    _zfDataDic = zfDataDic;
    NSArray *dayArray = zfDataDic[@"xAxis"];
    NSArray *dataArray = zfDataDic[@"series"];
    self.zfTotalCount = dataArray.count>0?dayArray.count:1;
    NSInteger count = (self.zfTotalCount>6)?6:self.zfTotalCount;
    self.zfItemWidth = scrollWidth/count;
    CGFloat totalWidth = viewPix(20)+self.zfItemWidth*self.zfTotalCount;
    self.zfScrollView.contentSize = CGSizeMake(totalWidth, scrollHeight);
    [self.zfScrollView setContentOffset:CGPointMake(totalWidth-scrollWidth-viewPix(10), 0)];
    
    for (NSInteger i=0; i<6; i++){
        LGDottedLineView *lineView = [self viewWithTag:5000+i];
        CGRect rect = lineView.frame;
        lineView.frame = CGRectMake(rect.origin.x, rect.origin.y, totalWidth+viewPix(30), lineHeight);
        [lineView setNeedsDisplay];
    }
    
    for (UIView *view in self.zfViewArray) {
        [view removeFromSuperview];
    }
    [self.zfViewArray removeAllObjects];
    
    if(_zfShapeLayer){
        [self.zfShapeLayer removeFromSuperlayer];
    }
    
    for (NSInteger i=0; i<dayArray.count; i++) {
//        NSArray *tempArray = [LGNSString(dayArray[i]) componentsSeparatedByString:@"-"];
//        NSString *dayString = [NSString stringWithFormat:@"%@/%@",tempArray[tempArray.count-2],tempArray[tempArray.count-1]];
        UILabel *dayLabel = [UILabel lableWithText:LGNSString(dayArray[i]) colorString:@"#333333" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        dayLabel.frame = CGRectMake(viewPix(10)+self.zfItemWidth*i, lineHeight*5.5, self.zfItemWidth, lineHeight);
        dayLabel.tag = 1000+i;
        [self.zfScrollView addSubview:dayLabel];
        [self.zfViewArray addObject:dayLabel];
    }
    
    NSMutableArray *pointArray = [NSMutableArray array];
    for (NSInteger i=0; i<dataArray.count; i++) {
        NSDictionary *tempDic = dataArray[i];
        NSString *status = LGNSString(tempDic[@"status"]);
        CGFloat value = [tempDic[@"value"] floatValue];
        CGFloat pointY = scrollHeight-((value-0)/2.0*lineHeight+viewPix(20)+lineHeight*0.5);
        UIButton *button = [UIButton buttonWithImage:self.iconDic[status] selectImage:self.iconDic[status]];
        button.bounds = CGRectMake(0, 0, viewPix(20), viewPix(20));
        button.center = CGPointMake(viewPix(10)+self.zfItemWidth/2.0+self.zfItemWidth*i, pointY);
        button.tag = 3000+i;
        [button addTarget:self action:@selector(pointButtonTouch:) forControlEvents:UIControlEventTouchUpInside];
        [self.zfScrollView addSubview:button];
        [self.zfViewArray addObject:button];
        
        UILabel *scoreLabel = [UILabel lableWithText:LGNSString(tempDic[@"value"]) colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        [self.zfScrollView addSubview:scoreLabel];
        [self.zfViewArray addObject:scoreLabel];
        CGFloat scoreY = pointY>(scrollHeight-viewPix(20)-lineHeight*2)?-viewPix(30):-viewPix(7);
        [scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(button.mas_bottom).offset(scoreY);
            make.centerX.equalTo(button);
        }];
        
        NSValue *point = [NSValue valueWithCGPoint:button.center];
        [pointArray addObject:point];
    }
    [self drawCurveLine:pointArray lineColor:@"#429BFF" superView:self.zfScrollView];
}


-(void)setCxDataDic:(NSDictionary *)cxDataDic{
    _cxDataDic = cxDataDic;
    NSArray *dayArray = cxDataDic[@"xAxis"];
    NSArray *dataArray = cxDataDic[@"series"];
    self.cxTotalCount = dataArray.count>0?dayArray.count:1;
    NSInteger count = (self.cxTotalCount>6)?6:self.cxTotalCount;
    self.cxItemWidth = scrollWidth/count;
    CGFloat totalWidth = viewPix(20)+self.cxItemWidth*self.cxTotalCount;
    self.cxScrollView.contentSize = CGSizeMake(totalWidth, scrollHeight);
    [self.cxScrollView setContentOffset:CGPointMake(totalWidth-scrollWidth-viewPix(10), 0)];
    
    for (NSInteger i=0; i<6; i++){
        LGDottedLineView *lineView = [self viewWithTag:6000+i];
        CGRect rect = lineView.frame;
        lineView.frame = CGRectMake(rect.origin.x, rect.origin.y, totalWidth+viewPix(30), lineHeight);
        [lineView setNeedsDisplay];
    }
    
    for (UIView *view in self.cxViewArray) {
        [view removeFromSuperview];
    }
    [self.cxViewArray removeAllObjects];
    
    if(_cxShapeLayer){
        [self.cxShapeLayer removeFromSuperlayer];
    }
    
    for (NSInteger i=0; i<dayArray.count; i++) {
//        NSArray *tempArray = [LGNSString(dayArray[i]) componentsSeparatedByString:@"-"];
//        NSString *dayString = [NSString stringWithFormat:@"%@/%@",tempArray[tempArray.count-2],tempArray[tempArray.count-1]];
        UILabel *dayLabel = [UILabel lableWithText:LGNSString(dayArray[i]) colorString:@"#333333" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        dayLabel.frame = CGRectMake(viewPix(10)+self.zfItemWidth*i, lineHeight*5.5, self.zfItemWidth, lineHeight);
        dayLabel.tag = 2000+i;
        [self.cxScrollView addSubview:dayLabel];
        [self.cxViewArray addObject:dayLabel];
    }
    
    NSMutableArray *pointArray = [NSMutableArray array];
    for (NSInteger i=0; i<dataArray.count; i++) {
        NSDictionary *tempDic = dataArray[i];
        NSString *status = LGNSString(tempDic[@"status"]);
        CGFloat value = [tempDic[@"value"] floatValue];
        CGFloat pointY = scrollHeight-((value-0)/2.0*lineHeight+viewPix(20)+lineHeight*0.5);
        UIButton *button = [UIButton buttonWithImage:self.iconDic[status] selectImage:self.iconDic[status]];
        button.bounds = CGRectMake(0, 0, viewPix(20), viewPix(20));
        button.center = CGPointMake(viewPix(10)+self.cxItemWidth/2.0+self.cxItemWidth*i, pointY);
        button.tag = 4000+i;
        [button addTarget:self action:@selector(pointButtonTouch:) forControlEvents:UIControlEventTouchUpInside];
        [self.cxScrollView addSubview:button];
        [self.cxViewArray addObject:button];
        
        UILabel *scoreLabel = [UILabel lableWithText:LGNSString(tempDic[@"value"]) colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        [self.cxScrollView addSubview:scoreLabel];
        [self.cxViewArray addObject:scoreLabel];
        CGFloat scoreY = pointY>(scrollHeight-viewPix(20)-lineHeight*2)?-viewPix(30):-viewPix(7);
        [scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(button.mas_bottom).offset(scoreY);
            make.centerX.equalTo(button);
        }];
        
        NSValue *point = [NSValue valueWithCGPoint:button.center];
        [pointArray addObject:point];
    }
    [self drawCurveLine:pointArray lineColor:@"#429BFF" superView:self.cxScrollView];
}

-(void)pointButtonTouch:(UIButton *)sender{
//    NSInteger index = sender.tag%1000;
//    for(NSInteger i=0; i<self.zfTotalCount; i++){
//        UIButton *highBtn = [self viewWithTag:2000+i];
//        UIButton *lowBtn = [self viewWithTag:3000+i];
//        highBtn.selected = (index == i)?YES:NO;
//        lowBtn.selected = (index == i)?YES:NO;
//    }
//    NSDictionary *highDic = @{@"title":@"高压",@"score":LGNSString(self.highArray[index][@"value"]),@"status":LGNSString(self.highArray[index][@"status"])};
//    NSDictionary *lowDic = @{@"title":@"低压",@"score":LGNSString(self.lowArray[index][@"value"]),@"status":LGNSString(self.lowArray[index][@"status"])};
//    NSArray *tempArray = @[highDic,lowDic];
//    CGPoint point = [self.scrollView convertPoint:sender.center toView:self.superview];
//
//    NSLog(@">>>???>>>%f--%f",point.x,point.y);
//    if(self.delegate && [self.delegate respondsToSelector:@selector(showAlertView:date:point:)]){
//        [self.delegate showAlertView:tempArray date:self.dayArray[index] point:point];
//    }
//
//    CGPoint point2 = [self.scrollView convertPoint:sender.center toView:self.superview.superview.superview];
//    if(self.delegate && [self.delegate respondsToSelector:@selector(showAlertView2:date:point:)]){
//        [self.delegate showAlertView2:tempArray date:self.dayArray[index] point:point2];
//    }
}

//画线
-(void)drawCurveLine:(NSArray *)arry lineColor:(NSString *)color superView:(LGScrollView *)scrollView{
    if(arry.count == 0) return;
    CGPoint startPoint = [[arry objectAtIndex:0] CGPointValue];
    CGPoint lastPoint;
    UIBezierPath *lineBeizer = [UIBezierPath bezierPath];
    [lineBeizer setLineWidth:2.0];
    [lineBeizer moveToPoint:startPoint];

    for (NSInteger i = 0;i < arry.count;i++ ) {
        if (i <arry.count-1 ) {
            CGPoint nowPoint = [[arry objectAtIndex:i] CGPointValue];
            CGPoint futPoint  = [[arry objectAtIndex:i+1] CGPointValue];
            [lineBeizer addCurveToPoint:futPoint controlPoint1:CGPointMake((nowPoint.x+futPoint.x)/2, nowPoint.y) controlPoint2:CGPointMake((nowPoint.x+futPoint.x)/2, futPoint.y)];
            if (i == arry.count-2) {
                [lineBeizer moveToPoint:futPoint];//添加连线
                lastPoint = futPoint;
            }
        }
    }
    
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.path = lineBeizer.CGPath;
    shapeLayer.fillColor = [UIColor clearColor].CGColor;
    shapeLayer.strokeColor = [UIColor colorWithString:color].CGColor;
    shapeLayer.lineWidth = 2.0;
    [scrollView.layer addSublayer:shapeLayer];
    if(scrollView == self.zfScrollView){
        self.zfShapeLayer = shapeLayer;
        for(NSInteger i=0; i<self.zfTotalCount; i++){
            UIButton *button = [self viewWithTag:3000+i];
            [self.zfScrollView bringSubviewToFront:button];
        }
    }else{
        self.cxShapeLayer = shapeLayer;
        for(NSInteger i=0; i<self.cxTotalCount; i++){
            UIButton *button = [self viewWithTag:4000+i];
            [self.cxScrollView bringSubviewToFront:button];
        }
    }
    
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self addSubview:self.baseView];
    [self.baseView addSubview:self.allButton];
    [self.baseView addSubview:self.patientBtn];
    [self.baseView addSubview:self.doctorBtn];
    [self.baseView addSubview:self.zfButton];
    [self.baseView addSubview:self.zfStatus];
    [self.baseView addSubview:self.zfScrollView];
    [self.baseView addSubview:self.cxButton];
    [self.baseView addSubview:self.cxStatus];
    [self.baseView addSubview:self.cxScrollView];
    
    NSArray *titleArray = @[@"10",@"8",@"6",@"4",@"2",@"0"];
    for (NSInteger i=0; i<titleArray.count; i++) {
        //Y轴标题
        UILabel *label = [UILabel lableWithText:titleArray[i] colorString:@"#333333" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        label.frame = CGRectMake(0, zfTopMargin+lineHeight*i, leftMargin, lineHeight);
        [self.baseView addSubview:label];
        //虚线
        LGDottedLineView *lineView = [[LGDottedLineView alloc]initWithFrame:CGRectMake(0, lineHeight*i, self.zfItemWidth*30+viewPix(50), lineHeight)];
        lineView.tag = 5000+i;
        [self.zfScrollView addSubview:lineView];
        
        //Y轴标题
        UILabel *label2 = [UILabel lableWithText:titleArray[i] colorString:@"#333333" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        label2.frame = CGRectMake(0, cxTopMargin+lineHeight*i, leftMargin, lineHeight);
        [self.baseView addSubview:label2];
        //虚线
        LGDottedLineView *lineView2 = [[LGDottedLineView alloc]initWithFrame:CGRectMake(0, lineHeight*i, self.zfItemWidth*30+viewPix(50), lineHeight)];
        lineView2.tag = 6000+i;
        [self.cxScrollView addSubview:lineView2];
    }
    
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc]initWithFrame:CGRectMake(viewPix(16), viewPix(16), Screen_W-viewPix(32), viewPix(520))];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 10;
    }
    return _baseView;
}

-(UIButton *)allButton{
    if(!_allButton){
        _allButton = [UIButton buttonWithTitle:@"全部" titleFont:LGFontWeight(14, UIFontWeightMedium) textColor:@"#909399" frame:CGRectMake(viewPix(8), viewPix(12), (Screen_W-viewPix(64))/3.0, viewPix(32))];
        [_allButton setTitleColor:[UIColor colorWithString:@"#5E8EF5"] forState:UIControlStateSelected];
        [_allButton setBackgroundColor:@"#EFEFEF" selectColor:@"#E5F1FF"];
        _allButton.cornerRidus = viewPix(16);
        _allButton.selected = YES;
        [_allButton addTarget:self action:@selector(itemButtonSelect:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _allButton;
}

-(UIButton *)patientBtn{
    if(!_patientBtn){
        _patientBtn = [UIButton buttonWithTitle:@"患者自评" titleFont:LGFontWeight(14, UIFontWeightMedium) textColor:@"#909399" frame:CGRectMake(kMaxX(self.allButton.frame)+viewPix(8), viewPix(12), (Screen_W-viewPix(64))/3.0, viewPix(32))];
        [_patientBtn setTitleColor:[UIColor colorWithString:@"#5E8EF5"] forState:UIControlStateSelected];
        [_patientBtn setBackgroundColor:@"#EFEFEF" selectColor:@"#E5F1FF"];
        _patientBtn.cornerRidus = viewPix(16);
        [_patientBtn addTarget:self action:@selector(itemButtonSelect:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _patientBtn;
}

-(UIButton *)doctorBtn{
    if(!_doctorBtn){
        _doctorBtn = [UIButton buttonWithTitle:@"医评" titleFont:LGFontWeight(14, UIFontWeightMedium) textColor:@"#909399" frame:CGRectMake(kMaxX(self.patientBtn.frame)+viewPix(8), viewPix(12), (Screen_W-viewPix(64))/3.0, viewPix(32))];
        [_doctorBtn setTitleColor:[UIColor colorWithString:@"#5E8EF5"] forState:UIControlStateSelected];
        [_doctorBtn setBackgroundColor:@"#EFEFEF" selectColor:@"#E5F1FF"];
        _doctorBtn.cornerRidus = viewPix(16);
        [_doctorBtn addTarget:self action:@selector(itemButtonSelect:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _doctorBtn;
}

-(UIButton *)zfButton{
    if(!_zfButton){
        _zfButton = [UIButton buttonWithTitle:@"中风风险" titleFont:LGFontWeight(18, UIFontWeightMedium) textColor:@"#282828" imageName:@"叹号提示"];
        _zfButton.frame = CGRectMake(viewPix(12), viewPix(50), viewPix(150), viewPix(37));
        _zfButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [_zfButton setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:3];
        [_zfButton addTarget:self action:@selector(showRiskTipView:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _zfButton;
}

-(UILabel *)zfStatus{
    if(!_zfStatus){
        _zfStatus = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _zfStatus.frame = CGRectMake(Screen_W-viewPix(32)-viewPix(113), kMinY(self.zfButton.frame), viewPix(100), viewPix(37));
    }
    return _zfStatus;
}

-(LGScrollView *)zfScrollView{
    if(!_zfScrollView){
        _zfScrollView = [[LGScrollView alloc]initWithFrame:CGRectMake(leftMargin, zfTopMargin, scrollWidth, scrollHeight)];
        _zfScrollView.contentSize = CGSizeMake(self.zfItemWidth*30+viewPix(20), scrollHeight);
        _zfScrollView.showsHorizontalScrollIndicator = NO;
        _zfScrollView.delegate = self;
    }
    return _zfScrollView;
}


-(UIButton *)cxButton{
    if(!_cxButton){
        _cxButton = [UIButton buttonWithTitle:@"出血风险" titleFont:LGFontWeight(18, UIFontWeightMedium) textColor:@"#282828" imageName:@"叹号提示"];
        _cxButton.frame = CGRectMake(viewPix(12), kMaxY(self.zfScrollView.frame)+viewPix(10), viewPix(150), viewPix(37));
        _cxButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [_cxButton setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:3];
        [_cxButton addTarget:self action:@selector(showRiskTipView:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cxButton;
}

-(UILabel *)cxStatus{
    if(!_cxStatus){
        _cxStatus = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _cxStatus.frame = CGRectMake(Screen_W-viewPix(32)-viewPix(113), kMinY(self.cxButton.frame), viewPix(100), viewPix(37));
    }
    return _cxStatus;
}

-(LGScrollView *)cxScrollView{
    if(!_cxScrollView){
        _cxScrollView = [[LGScrollView alloc]initWithFrame:CGRectMake(leftMargin, cxTopMargin, scrollWidth, scrollHeight)];
        _cxScrollView.contentSize = CGSizeMake(self.cxItemWidth*30+viewPix(20), scrollHeight);
        _cxScrollView.showsHorizontalScrollIndicator = NO;
        _cxScrollView.delegate = self;
    }
    return _cxScrollView;
}

-(NSMutableArray *)zfViewArray{
    if(!_zfViewArray){
        _zfViewArray = [NSMutableArray array];
    }
    return _zfViewArray;
}

-(NSMutableArray *)cxViewArray{
    if(!_cxViewArray){
        _cxViewArray = [NSMutableArray array];
    }
    return _cxViewArray;
}

@end
